package sum.CityForeignMarriages;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class SumCityFoMarriagesBean implements WritableComparable<SumCityFoMarriagesBean> {
    private String province;
    private String city;

    public SumCityFoMarriagesBean(){

    }

    public SumCityFoMarriagesBean(String province,String city){
        this.province = province;
        this.city = city;
    }

    public void set(String province,String city){
        this.province = province;
        this.city = city;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    @Override
    public String toString() {
        return province + "\t" + city;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(province);
        dataOutput.writeUTF(city);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.province = dataInput.readUTF();
        this.city = dataInput.readUTF();
    }

    @Override
    public int compareTo(SumCityFoMarriagesBean o) {
        int res = this.province.compareTo(o.province);
        if(res!=0){
            return res;
        }else {
            return this.city.compareTo(o.city);
        }
    }
}
